From 95fe3ec0c9c26a7a667541b81f2a190bce9d7abc Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?utf8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 3 Mar 2016 17:17:25 +0000 Subject: [PATCH] GDK W32: Fix redrawing during drag-move with no composition --- gdk/win32/gdkwindow-win32.c | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index c84ceb8986..33488798a3 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -3133,7 +3133,12 @@ gdk_win32_window_do_move_resize_drag (GdkWindow *window, rect.top != new_rect.top)) { POINT window_position; + SIZE window_size; BLENDFUNCTION blender; + HDC hdc; + SIZE *window_size_ptr; + POINT source_point = { 0, 0 }; + POINT *source_point_ptr; context->native_move_resize_pending = FALSE; @@ -3150,6 +3155,8 @@ gdk_win32_window_do_move_resize_drag (GdkWindow *window, window_position.x = new_rect.left; window_position.y = new_rect.top; + window_size.cx = new_rect.right - new_rect.left; + window_size.cy = new_rect.bottom - new_rect.top; blender.BlendOp = AC_SRC_OVER; blender.BlendFlags = 0; @@ -3157,16 +3164,41 @@ gdk_win32_window_do_move_resize_drag (GdkWindow *window, blender.SourceConstantAlpha = impl->layered_opacity * 255; /* Size didn't change, so move immediately, no need to wait for redraw */ + /* Strictly speaking, we don't need to supply hdc, source_point and + * window_size here. However, without these arguments + * the window moves but does not update its contents on Windows 7 when + * desktop composition is off. This forces us to provide hdc and + * source_point. window_size is here to avoid the function + * inexplicably failing with error 317. + */ if (impl->layered) - API_CALL (UpdateLayeredWindow, (GDK_WINDOW_HWND (window), NULL, - &window_position, NULL, NULL, NULL, - 0, &blender, ULW_ALPHA)); + { + if (gdk_screen_is_composited (gdk_window_get_screen (window))) + { + hdc = NULL; + window_size_ptr = NULL; + source_point_ptr = NULL; + } + else + { + hdc = cairo_win32_surface_get_dc (impl->cache_surface); + window_size_ptr = &window_size; + source_point_ptr = &source_point; + } + + API_CALL (UpdateLayeredWindow, (GDK_WINDOW_HWND (window), NULL, + &window_position, window_size_ptr, + hdc, source_point_ptr, + 0, &blender, ULW_ALPHA)); + } else - API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), - SWP_NOZORDER_SPECIFIED, - window_position.x, window_position.y, - 0, 0, - SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE)); + { + API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), + SWP_NOZORDER_SPECIFIED, + window_position.x, window_position.y, + 0, 0, + SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE)); + } } } -- 2.30.2